package com.example.carconsumer.controller.dl.admin;

import com.alibaba.dubbo.config.annotation.Reference;
import com.example.carinterface.service.dl.admin.InsuranceService;
import com.example.carinterface.utils.ResultJson;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("admin/insurance")
@Api(tags = "admin - 保险管理")
public class InsuranceController {

    @Reference(check = false)
    private InsuranceService insuranceService;


    @ApiOperation("查询保险订单")
    @PostMapping("/findAllInsuranceOrder")
    public ResultJson<List<Map<String, Object>>> findAllInsuranceOrder(@ApiParam("不传查全部，\n" +
            "like:用户名或者手机号(用于搜索).\n" +
            "id：用于查看详情") @RequestBody(required = false) Map<String,Object> map){
        return insuranceService.findAllInsuranceOrder(map);
    }

    @ApiOperation("添加保单")
    @PostMapping("/addInsuranceOrder")
    public ResultJson<String> addInsuranceOrder(@ApiParam() @RequestBody Map<String,Object> map){
        return insuranceService.addInsuranceOrder(map);
    }

    @ApiOperation("修改状态（审核）")
    @PostMapping("/updateInsuranceState")
    public ResultJson<String> updateInsuranceState(@ApiParam("id:保单id，\n" +
            "state:状态 ,'订单状态:1、车辆信息待审核；2、待录入信息；3、待录入保费；4、待付款；5、待录入验证码；6、已完成',")@RequestBody Map<String,Object> map){
        return insuranceService.updateInsuranceState(map);
    }
}
